package com.vegetable.modules.controller.finance;

import com.vegetable.common.annotation.SysLog;
import com.vegetable.common.utils.R;
import com.vegetable.modules.controller.AbstractController;
import com.vegetable.modules.service.finance.ManualPaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 手动支付控制器
 *
 * @author Qoder
 */
@Slf4j
@RestController
@RequestMapping("/payment/manual")
@Api(value = "手动支付", tags = "手动支付")
public class ManualPaymentController extends AbstractController {

    @Autowired
    private ManualPaymentService manualPaymentService;

    /**
     * 执行手动支付
     */
    @SysLog(value = "执行手动支付")
    @PostMapping("/execute")
    @ApiOperation(value = "执行手动支付", notes = "对审批通过但未自动支付的付款记录执行手动支付")
    public R executeManualPayment(@RequestParam Long paymentId) {
        log.info("开始执行手动支付，付款ID: {}", paymentId);
        return manualPaymentService.executeManualPayment(paymentId);
    }
    
    /**
     * 根据付款ID查询付款审批中的收款人信息
     */
    @SysLog(value = "查询付款审批中的收款人信息")
    @GetMapping("/payee-info")
    @ApiOperation(value = "查询付款审批中的收款人信息", notes = "根据付款ID查询付款审批中的收款人银行卡号、开户银行和全称")
    public R<Map<String, String>> getPayeeInfoByPaymentId(@RequestParam Long paymentId) {
        log.info("开始查询付款审批中的收款人信息，付款ID: {}", paymentId);
        return manualPaymentService.getPayeeInfoByPaymentId(paymentId);
    }
}